/*    */ package com.zimbra.cs.service.admin;
/*    */ 
/*    */ import com.zimbra.common.service.ServiceException;
/*    */ import com.zimbra.common.soap.Element;
/*    */ import com.zimbra.cs.account.Provisioning;
/*    */ import com.zimbra.cs.account.accesscontrol.AdminRight;
/*    */ import com.zimbra.cs.account.accesscontrol.Rights.Admin;
/*    */ import com.zimbra.cs.volume.Volume;
/*    */ import com.zimbra.cs.volume.Volume.Builder;
/*    */ import com.zimbra.cs.volume.VolumeManager;
/*    */ import com.zimbra.soap.JaxbUtil;
/*    */ import com.zimbra.soap.ZimbraSoapContext;
/*    */ import com.zimbra.soap.admin.message.CreateVolumeRequest;
/*    */ import com.zimbra.soap.admin.message.CreateVolumeResponse;
/*    */ import com.zimbra.soap.admin.type.VolumeInfo;
/*    */ import java.util.List;
/*    */ import java.util.Map;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public final class CreateVolume
/*    */   extends AdminDocumentHandler
/*    */ {
/*    */   public Element handle(Element req, Map<String, Object> ctx)
/*    */     throws ServiceException
/*    */   {
/* 41 */     ZimbraSoapContext zsc = getZimbraSoapContext(ctx);
/* 42 */     return zsc.jaxbToElement(handle((CreateVolumeRequest)JaxbUtil.elementToJaxb(req), ctx));
/*    */   }
/*    */   
/*    */   private CreateVolumeResponse handle(CreateVolumeRequest req, Map<String, Object> ctx) throws ServiceException {
/* 46 */     ZimbraSoapContext zsc = getZimbraSoapContext(ctx);
/* 47 */     checkRight(zsc, ctx, Provisioning.getInstance().getLocalServer(), Rights.Admin.R_manageVolume);
/*    */     
/* 49 */     Volume vol = VolumeManager.getInstance().create(toVolume(req.getVolume()));
/* 50 */     return new CreateVolumeResponse(vol.toJAXB());
/*    */   }
/*    */   
/*    */   private Volume toVolume(VolumeInfo vol) throws ServiceException {
/* 54 */     return Volume.builder().setType(vol.getType()).setName(vol.getName()).setPath(vol.getRootPath(), true).setCompressBlobs(vol.isCompressBlobs()).setCompressionThreshold(vol.getCompressionThreshold()).build();
/*    */   }
/*    */   
/*    */ 
/*    */ 
/*    */   public void docRights(List<AdminRight> relatedRights, List<String> notes)
/*    */   {
/* 61 */     relatedRights.add(Rights.Admin.R_manageVolume);
/*    */   }
/*    */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/service/admin/CreateVolume.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */